package com.jsbs.iam.user.controller;

import com.alibaba.fastjson.JSON;
import com.jsbs.iam.common.core.dto.Result;
import com.jsbs.iam.user.service.IamApplyMenuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author junwc
 * @Date 2022/12/8
 * @Version 1.0
 */
@RestController
@RequestMapping("/iam/user")
public class IamMenuInfoApiController extends BaseController{
    private static final Logger logger = LoggerFactory.getLogger(IamMenuInfoApiController.class);

    @Autowired
    private IamApplyMenuService iamApplyMenuService;

    /**
     * 功能描述：根据菜单编码获取菜单数据
     * @param menuCodeList
     * @return
     */
    @PostMapping("/getMenuInfoList")
    public Result getMenuInfoList(@RequestBody List<String> menuCodeList) {
        try {
            logger.info("Route==>IamMenuInfoApiController method=getMenuInfoList 根据菜单编码查询菜单信息，入参:{}", JSON.toJSONString(menuCodeList));
            return Result.success(iamApplyMenuService.queryByMenuCode(menuCodeList));
        }catch (Exception e){
            logger.error("Route==>IamMenuInfoApiController method=getMenuInfoList 根据菜单编码查询菜单信息异常：{}，入参:{}", e.getMessage(), JSON.toJSONString(menuCodeList));
            return handleException(e);
        }
    }


}
